package com.atguigu.tingshu.model.search;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 专辑索引
 * @author sun
 */
@Data
@Document(indexName = "albuminfo")
//目的：防止json字符串转成实体对象时因未识别字段报错
@JsonIgnoreProperties(ignoreUnknown = true)
public class AlbumInfoIndex implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 专辑Id
     */
    @Id
    private Long id;
    /**
     * 专辑标题
     *  <p>
     *      es 中能分词的字段，这个字段数据类型必须是 text！keyword 不分词！ analyzer = "ik_max_word"
     *  </p>
     */
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String albumTitle;
    /**
     * 专辑简介
     */
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String albumIntro;
    /**
     * 播音者名称
     */
    @Field(type = FieldType.Keyword)
    private String announcerName;
    /**
     * 封面图片地址
     */
    @Field(type = FieldType.Keyword, index = false)
    private String coverUrl;
    /**
     * 包含的音频数量
     */
    @Field(type = FieldType.Long, index = false)
    private Integer includeTrackCount;
    /**
     * 专辑是否完结：0-否；1-完结
     */
    @Field(type = FieldType.Long, index = false)
    private String isFinished;
    /**
     * 专辑价格类型：免费、vip免费、付费
     */
    @Field(type = FieldType.Keyword, index = false)
    private String payType;
    /**
     * 创建时间
     */
    @Field(type = FieldType.Date,format = DateFormat.date_time, pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    /**
     * 一级分类id
     */
    @Field(type = FieldType.Long)
    private Long category1Id;
    /**
     * 二级分类id
     */
    @Field(type = FieldType.Long)
    private Long category2Id;
    /**
     * 三级分类id
     */
    @Field(type = FieldType.Long)
    private Long category3Id;
    /**
     * 播放量
     */
    @Field(type = FieldType.Integer)
    private Integer playStatNum = 0;
    /**
     * 订阅量
     */
    @Field(type = FieldType.Integer)
    private Integer subscribeStatNum = 0;
    /**
     * 购买量
     */
    @Field(type = FieldType.Integer)
    private Integer buyStatNum = 0;
    /**
     * 评论量
     */
    @Field(type = FieldType.Integer)
    private Integer commentStatNum = 0;
    /**
     * 热度
     */
    @Field(type = FieldType.Double)
    private Double hotScore = 0d;
    /**
     * 专辑属性值
     * <p>
     *     Nested 支持嵌套查询
     * </p>
     */
    @Field(type = FieldType.Nested)
    private List<AttributeValueIndex> attributeValueIndexList;

}
